package com.project.service;

import com.project.bean.UserBean;
import com.project.dao.IUserDao;
import com.project.server.Request;
import com.project.server.Response;
import com.project.uitl.DaoFactory;
import com.project.uitl.WebServlet;

import java.time.LocalDate;
@WebServlet("add")
public class AddService implements Servlet {
    private IUserDao dao =(IUserDao) DaoFactory.getDao("IUserDao");

    public void service(Request request, Response response) {
        String name = request.getParameter("userName");
        String pwd = request.getParameter("pwd");
        String birthday = request.getParameter("birthday");
        UserBean user = new UserBean(name, pwd, LocalDate.parse(birthday));

        dao.add(user);

        FindAllService findAll = new FindAllService();
        findAll.service(request, response);
    }

}
